<?php
/**
 * Created by PhpStorm.
 * User: zd
 * Date: 2018/8/13
 * Time: 16:51
 */

namespace app\api\controller\v1;


use app\api\validate\IDCollection;
use app\api\model\Theme as ThemeModel;
use app\api\validate\IDMustBePositiveInt;
use app\lib\exception\ThemeException;

class Theme
{
    /**
     * Theme数据请求
     * @param string $ids
     * @url theme
     * @return \think\response\Json
     * @throws ThemeException
     */
    public function getSimpleList($ids=''){
        (new IDCollection())->goCheck();
        $ids = explode(',',$ids);
        $result =  ThemeModel::getThemeByIDs($ids);
        if($result->isEmpty()){
            throw new ThemeException();
        }
        return $result;
    }
    /**
     * 请求theme详情
     * @param $id
     * @url theme/:id
     * @return \think\response\Json
     * @throws ThemeException
     */
    public function getComplexOne($id){
        (new IDMustBePositiveInt())->goCheck();
        $result = ThemeModel::getComplexByID($id);
        if (empty($result)){
            throw new ThemeException();
        }
        return $result;
    }
}